cmake_minimum_required(VERSION 3.8.2)

project(dataservice
	VERSION 1.0.0 # <major>[.<minor>[.<patch>[.<tweak>]]]
	LANGUAGES C
)

set(CMAKE_BUILD_TYPE "Debug")
#set(CMAKE_BUILD_TYPE "Release")

set(CMAKE_VERBOSE_MAKEFILE ON)

# 增加多线程支持
set(CMAKE_C_FLAGS "-pthread ${CMAKE_C_FLAGS}")

################################################################################
## 添加头文件
include_directories(./include)
include_directories(./thirdparty)
include_directories(./thirdparty/easylogger/easylogger/inc)
include_directories(./thirdparty/easylogger/easylogger/plugins/file)
#include_directories(./thirdparty/easylogger/easylogger/plugins/flash)
include_directories(./thirdparty/threadpool/include)
include_directories(./thirdparty/tinyini)
################################################################################

################################################################################
## 添加源文件
AUX_SOURCE_DIRECTORY(. SRCS)
file(GLOB SRC
		./src/*.c
		./test/*.c)
list(APPEND SRCS ${SRC})

## thirdparty源文件
file(GLOB SRC
		./thirdparty/easylogger/easylogger/plugins/file/*.c
		#./thirdparty/easylogger/easylogger/plugins/flash/*.c
		./thirdparty/easylogger/easylogger/port/*.c
		./thirdparty/easylogger/easylogger/src/*.c
		./thirdparty/tinyini/tiny_ini_file.c
		./thirdparty/threadpool/source/*.c)
list(APPEND SRCS ${SRC})
MESSAGE(STATUS "${CMAKE_CURRENT_LIST_LINE} ${SRC}")
list(APPEND SRCS ${SRC})
################################################################################

add_executable(${PROJECT_NAME} ${SRCS})

add_custom_command(TARGET ${PROJECT_NAME}
	POST_BUILD
	COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/config $<TARGET_FILE_DIR:${PROJECT_NAME}>/config
	COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_FILE_DIR:${PROJECT_NAME}>/logs
)

add_executable(udp_client tools/tcp_udp/udp_client.c)
